package com.preresearch.recyclerview;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.preresearch.recyclerview.adapter.LinearRecyclerAdapter;


public class GridRecyclerActivity extends Activity {

    private static final String TAG = GridRecyclerActivity.class.getSimpleName();

    private RecyclerView mRecyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);

        // GridLayoutManager 类似于GridView
        // LinearLayoutManager 类似于ListView
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        // 设置排列为水平排列。
//        layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        // 设置布局管理器
        mRecyclerView.setLayoutManager(layoutManager);

        String[] dataset = new String[100];
        for (int i = 0; i < dataset.length; i++) {
            dataset[i] = "item" + i;
        }
        LinearRecyclerAdapter mAdapter = new LinearRecyclerAdapter(dataset);
        mRecyclerView.setAdapter(mAdapter);
    }

}